home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / Pour scroll reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.3 KB  |  118 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Pour scroll reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 2
  32. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  33. #define theWindowWidth (boundsRect.right-boundsRect.left)
  34.  
  35. pascal short PourScrollReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* Scroll down in tiny strips, starting at the right and moving left.  Scroll
  38.    strips 1-(N), then strips 1-(N+1), etc.  When strip 1 is done, don't do it
  39.    anymore!  (Duh, but this was difficult to get right.)  So only scroll strips
  40.    2-(N), and so on. */
  41.    
  42. pascal short PourScrollReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  43. {
  44.     Rect            *theRect, *dest;
  45.     Rect            scrollsource;
  46.     int                i;
  47.     int                startstrip,endstrip;
  48.     int                ScrollSize, BoxSize;
  49.     int                NumStrips;
  50.     
  51.     ScrollSize=theWindowHeight/50;
  52.     NumStrips=theWindowWidth/4;
  53.     BoxSize=theWindowWidth/NumStrips;
  54.     dest=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  55.     if (dest==0L)
  56.         return -1;        /* memory error */
  57.     theRect=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  58.     if (theRect==0L)
  59.     {
  60.         DisposePtr(dest);
  61.         return -1;        /* memory error */
  62.     }
  63.     
  64.     SetRect(&scrollsource, boundsRect.right-BoxSize, boundsRect.top,
  65.         boundsRect.right, boundsRect.bottom);
  66.         
  67.     for (i=0; i<NumStrips; i++)
  68.     {
  69.         dest[i].top = theWindowHeight-ScrollSize;
  70.         dest[i].bottom=theWindowHeight;
  71.         dest[i].left=theWindowWidth-(i+1)*BoxSize;
  72.         dest[i].right=dest[i].left+BoxSize;
  73.         OffsetRect(&(dest[i]), boundsRect.left, boundsRect.top);
  74.         
  75.         theRect[i].top=0;
  76.         theRect[i].bottom=ScrollSize;
  77.         theRect[i].left=theWindowWidth-(i+1)*BoxSize;
  78.         theRect[i].right=theRect[i].left+BoxSize;
  79.         OffsetRect(&(theRect[i]), boundsRect.left, boundsRect.top);
  80.     }
  81.     
  82.     startstrip=0;
  83.     endstrip=1;
  84.     do
  85.     {
  86.         StartTiming();
  87.         
  88.         ScrollRect(&scrollsource, 0, -ScrollSize, 0L);
  89.         
  90.         for (i=startstrip; i<endstrip; i++)
  91.         {
  92.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  93.                     &theRect[i], &dest[i], 0, 0L);
  94.             theRect[i].bottom+=ScrollSize;
  95.             theRect[i].top+=ScrollSize;
  96.         }
  97.         
  98.         if (endstrip<NumStrips)
  99.         {
  100.             endstrip++;
  101.             scrollsource.left-=BoxSize;
  102.         }
  103.         if (theRect[startstrip].top>=theWindowHeight)
  104.         {
  105.             startstrip++;
  106.             scrollsource.right-=BoxSize;
  107.         }
  108.         
  109.         TimeCorrection(CorrectTime);
  110.     }
  111.     while (startstrip<endstrip);
  112.     
  113.     DisposePtr(dest);
  114.     DisposePtr(theRect);
  115.     
  116.     return 0;
  117. }
  118.